<template>
  <div>
    <div class="tips mb20">
      <p>
        <i></i>
        应收:项目应收总和
      </p>
      <p>
        <i></i>
        成本（支出）:该项目支出总和
      </p>
    </div>
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="项目名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入项目名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          plain
        >搜索
        </el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
        >重置
        </el-button
        >
      </el-form-item>
    </el-form>
    <el-table
      v-loading="loading"
      :data="postList"
    >
      <el-table-column label="项目名称" align="center" prop="name"/>
      <el-table-column
        label="应收"
        align="center"
      >
        <template slot-scope="scope">
          ¥{{scope.row.contractMoney}}
        </template>
      </el-table-column>
      <el-table-column
        label="成本（支出）"
        align="center"
      >
        <template slot-scope="scope">
          ¥0
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {
  listProject,
  delProject
} from "@/api/system/project";
import zhudian from '@/components/zhudian'

export default {
  name: "StagnationPoint",
  dicts: ['sys_stagnation_type', 'sys_post_nature'],
  components: {zhudian},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      postList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        postCode: undefined,
        postName: undefined,
        status: undefined
      },
      param: null,
      detailVisible: false,
      zhudianVisible: false,
      activeName: 'logLine'
    };
  },
  watch: {},
  created() {
    this.loading = false
    this.getList()
  },
  methods: {
    /** 查询岗位列表 */
    getList() {
      this.loading = true;
      listProject(this.queryParams).then(response => {
        this.postList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleUpdate(row) {
      this.param = JSON.parse(JSON.stringify(row))
      this.detailVisible = true
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.postId)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.param = 0
      this.detailVisible = true
    },
    handleViewTeam(row) {
      this.$router.push(`/project/detail/index/${row.id}`)
      // this.param = JSON.parse(JSON.stringify(row))
      // this.zhudianVisible = true
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$modal.confirm('是否确认删除执勤点为"' + row.name + '"的数据项？').then(function () {
        return delProject(row.id);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/stagnation_point/export', {
        ...this.queryParams
      }, `post_${new Date().getTime()}.xlsx`)
    },
    /** 排序触发事件 */
    handleSortChange(column, prop, order) {
      this.queryParams.orderByColumn = column.prop;
      this.queryParams.isAsc = column.order;
      this.getList();
    },
  }
};
</script>
<style lang="scss" scoped>
.points-map {
  height: 400px;
}

.points-map__tip {
  color: #010101;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
}

.point-radius {
  margin-bottom: 20px;
  padding: 0 20px;

  .point-radius__len {
    margin-top: 10px;
    display: flex;
    display: -webkit-flex;
    justify-content: space-between;
    color: #010101;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
  }
}

.mapBox {
  margin-bottom: 20px;
  padding: 0 20px;
}
</style>

